package org.handsomezhi.shortlink.admin.config;


import lombok.RequiredArgsConstructor;
import org.handsomezhi.shortlink.admin.util.interceptor.RefreshInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;



@Configuration
@RequiredArgsConstructor
public class MvcConfig implements WebMvcConfigurer {


    private final  StringRedisTemplate stringRedisTemplate;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new RefreshInterceptor(stringRedisTemplate)).addPathPatterns("/**")
                .excludePathPatterns(
                        "/api/short-link/admin/v1/user/login",
                        "/api/short-link/admin/v1/user",
                        "/api/short-link/admin/v1/user/has-username"
                ).order(1);
    }
}
